package day_01.observer_mode_2;

import java.util.Observable;

public class WeatherData extends Observable {
    // 温度
    private float temp;
    // 湿度
    private float humidity;
    // 气压
    private float pressure;

    public WeatherData() { }

    public void measurementsChanged(){
        setChanged();
        notifyObservers();
    }

    /**
     * 气象站设置新的值
     */
    public void setMeasurements(float temp, float humidity, float pressure){
        this.temp = temp;
        this.humidity = humidity;
        this.pressure = pressure;
        measurementsChanged();
    }

    // 观察者会利用这些Getter方法取得WeatherData的状态
    public float getTemp() {
        return temp;
    }

    public float getHumidity() {
        return humidity;
    }

    public float getPressure() {
        return pressure;
    }
}
